#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
const int N = 1e5 + 10;

int n;
struct Student{
	int num;
	int x, y;
	int index;
}stu[N];
// cmp 很有意思
// 分好类
bool cmp(Student &a, Student &b)
{

	if((a.x + a.y) != b.x + b.y)
	{
		return a.x + a.y > b.x + b.y;
	}
	else if(a.x != b.x)
	{
		return a.x > b.x;
	}
	else {
		return a.num < b.num;
	}
}

int main()
{
	int n, low, high;
	cin >> n >> low >> high;
	int total = n;
	// 相当于开了一个二维数组
	vector<Student> v[4];
	for(int i = 0; i < n; i ++)
	{
		int num;
		int x, y;
		cin >> num >> x >> y;
		if(x < low || y < low)
		{
			total --;
		}
		else if(x >= high && y >= high)
		{
			v[0].push_back({num, x, y});
		} 
		else if(x >= high && y < high)
		{
			v[1].push_back({num, x, y});
		} 
		else if(x < high  && y < high && x >= y)
		{
			v[2].push_back({num, x, y});
		} 
		else 
		{
			v[3].push_back({num, x, y});
		}
	}
	cout << total << endl;
	for(int i = 0; i < 4; i ++)
	{
		sort(v[i].begin(), v[i].end(), cmp);
		for(int j = 0; j < v[i].size(); j ++)
		{
			auto t = v[i][j];
			cout << t.num << " " << t.x << " " << t.y << endl;
		}
	}
	return 0;
}